/**
 * Created by dev-001 on 2017/2/27.
 * 问题
 */
import mongoose from 'mongoose';
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;

const PositionSchema = new Schema({
    x: Number,
    y: Number
});
const QuestionNoSchema = new Schema({
    no: Number
});

const QuestionSchema = new Schema({
    name: String,
    exam: {
        type: ObjectId,
        ref: 'Exam'
    },
    qid: Number,//题号
    type: Number,
    score: Number,
    answer: String,
    points: [{
        type: ObjectId,
        ref: 'Point'
    }],
    difficulty: Number, //难度
    abilities: [{
        type: ObjectId,
        ref: 'Ability'
    }], //考察能力
    teacher: {
        type: ObjectId,
        ref: 'Teacher'
    },//创建者
    group: {
        type: ObjectId,
        ref: 'QuestionGroup'
    },//题组
    createdAt: Date,
    updatedAt: Date
});

QuestionSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

export default mongoose.model('Question', QuestionSchema);